package com.cloudz.iptv.player.base;

import android.content.Context;

import com.cloudz.iptv.player.base.cover.CompleteCover;
import com.cloudz.iptv.player.base.cover.ControllerCover;
import com.cloudz.iptv.player.base.cover.ErrorCover;
import com.cloudz.iptv.player.base.cover.LoadingCover;
import com.kk.taurus.playerbase.receiver.GroupValue;
import com.kk.taurus.playerbase.receiver.ReceiverGroup;

import static com.cloudz.iptv.player.base.DataInter.ReceiverKey.KEY_COMPLETE_COVER;
import static com.cloudz.iptv.player.base.DataInter.ReceiverKey.KEY_CONTROLLER_COVER;
import static com.cloudz.iptv.player.base.DataInter.ReceiverKey.KEY_ERROR_COVER;
import static com.cloudz.iptv.player.base.DataInter.ReceiverKey.KEY_LOADING_COVER;


/**
 * @File Name: iptv.cloudz.com.myplayer.play
 * @Author: YJ //作者及
 * @Date: 2019-02-19 16:13//完成日期
 * @Description: // 描述
 * @Version: v0.0.1 // 版本信息
 * @Function List: // 主要函数及其功能
 * @Others: // 其它内容的说明
 * @History: // 历史修改记录
 */
public class ReceiverGroupManager
{
    private static ReceiverGroupManager i;

    private ReceiverGroupManager()
    {
    }

    public static ReceiverGroupManager get()
    {
        if (null == i)
        {
            synchronized (ReceiverGroupManager.class)
            {
                if (null == i)
                {
                    i = new ReceiverGroupManager();
                }
            }
        }
        return i;
    }

    public ReceiverGroup getReceiverGroup(Context context)
    {
        return getReceiverGroup(context, null);
    }

    public ReceiverGroup getReceiverGroup(Context context, GroupValue groupValue)
    {
        ReceiverGroup receiverGroup = new ReceiverGroup(groupValue);
        //Loading组件
        receiverGroup.addReceiver(KEY_LOADING_COVER, new LoadingCover(context));
        //Controller组件
        ControllerCover controllerCover = new ControllerCover(context);
        receiverGroup.addReceiver(KEY_CONTROLLER_COVER, controllerCover);

        //receiverGroup.addReceiver(KEY_GESTURE_COVER, new GestureCover(context));
        //CompleteCover组件
        receiverGroup.addReceiver(KEY_COMPLETE_COVER, new CompleteCover(context));
        //Error组件
        receiverGroup.addReceiver(KEY_ERROR_COVER, new ErrorCover(context));
        return receiverGroup;
    }
}
